package com.shawn.spring.boot.mybatisplus.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteByIdWithFill;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author shawn
 * @since 2020/8/30
 */
@Configuration
@EnableTransactionManagement
@MapperScan("com.shawn.spring.boot.mybatisplus.mapper")
public class MybatisPlusConfig {

  // 分页插件
  @Bean
  public PaginationInnerInterceptor paginationInterceptor() {
    PaginationInnerInterceptor interceptor = new PaginationInnerInterceptor();
    interceptor.setDbType(DbType.MYSQL);
    interceptor.setMaxLimit(500l);
    return interceptor;
  }

  @Bean
  public LogicDeleteByIdWithFill sqlInjector() {
    return new LogicDeleteByIdWithFill();
  }
}
